/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            routePlanInfo: {
                plans: [],
                inspectionRouteId: '',
             
            }
        },
        _initMethod: function () {
        },
        _initEvent: function () {
            vc.on('routePlan', 'switch', function (_data) {
                $that.routePlanInfo.inspectionRouteId = _data.inspectionRouteId;
                $that.routePlanInfo.inspectionPlanId = _data.inspectionPlanId;

                $that._loadRoutePlanData(DEFAULT_PAGE, DEFAULT_ROWS);
             
            });
            vc.on('routePlan', 'paginationPlus', 'page_event',
                function (_currentPage) {
                    $that._loadRoutePlanData(_currentPage, DEFAULT_ROWS);
                });
            vc.on('routePlan', 'notify', function (_data) {
                $that._loadRoutePlanData(DEFAULT_PAGE, DEFAULT_ROWS);
            })
        },
        methods: {
           
            _loadRoutePlanData: function (_page, _row) {
                let param = {
                    params: {
                        communityId: vc.getCurrentCommunity().communityId,
                        inspectionRouteId: $that.routePlanInfo.inspectionRouteId,
                        inspectionPlanId:$that.routePlanInfo.inspectionPlanId,
                        page: _page,
                        row: _row
                    }
                };
                //发送get请求
                vc.http.apiGet('/inspection.queryRouteInspectionPlan',
                    param,
                    function (json) {
                        let _json = JSON.parse(json);
                        $that.routePlanInfo.plans = _json.data;
                        vc.emit('routePlan', 'paginationPlus', 'init', {
                            total: _json.records,
                            dataCount: _json.total,
                            currentPage: _page
                        });
                    },
                    function () {
                        console.log('请求失败处理');
                    }
                );
            },
            //查询
            _qureyRoutePlan: function () {
                $that._loadRoutePlanData(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            //重置
            _resetRoutePlan: function () {
                $that.routePlanInfo.roomNum = "";
                $that._loadRoutePlanData(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            
        }
    });
})(window.vc);